const Koa = require("koa");
const app = new Koa();
const routes = require("./router/index");
const chalk = require("chalk");
const views = require("koa-views");
const path = require("path");
const config = require("./helpper/config");

// app.use(views(path.resolve(__dirname, "public"), {}));

app.use(routes);

app.use(async (ctx: any) => {
  ctx.status = 404;
  ctx.body = "not found!";
});

const env = process.env.NODE_ENV ? process.env.NODE_ENV : "development";
const port = 3000;
app.listen(port, () => {
  console.log(
    `The environment of app is ${chalk.yellow(env)},port is ${chalk.yellow(
      port
    )}！`
  );
});
